package com.ethanzzh.ethanzzh_xdclass.mapper;

import com.ethanzzh.ethanzzh_xdclass.model.pojo.VideoOrder;
import org.apache.ibatis.annotations.Options;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import tk.mybatis.mapper.common.Mapper;

import java.util.List;


@org.apache.ibatis.annotations.Mapper
public interface VideoOrderMapper extends Mapper<VideoOrder> {

    @Select("select * from video_order where id=#{order_id} and del = 0")
    VideoOrder findById(@Param("order_id") int id);


    @Select("select * from video_order where out_trade_no = #{out_trade_no} and del = 0")
    VideoOrder findByOutTradeNo(@Param("out_trade_no") String outTradeNo);

    @Update("update video_order set del=0 where id = #{id} and user_id = #{userId}")
    int del(@Param("id") int id, @Param("userId") int userId);

    @Select("select * from video_order where user_id = #{userId}")
    List<VideoOrder> findMyOrderList(int userId);

    //根据订单流水号更新
    @Update("update video_order set state=#{state}, notify_time=#{notifyTime},openid=#{openid} where out_trade_no = #{outTradeNo} and state = 0 and del=0 ")
    int updateVideoOrderByOutTradeNo(VideoOrder videoOrder);
}